home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / mail / pine3.96.tar.gz / pine3.96.tar / pine3.96 / imap / ANSI / c-client / dummymac.c < prev    next >
C/C++ Source or Header  |  1994-05-30  |  11KB  |  471 lines

  1. /*
  2.  * Program:    Dummy routines for Mac
  3.  *
  4.  * Author:    Mark Crispin
  5.  *        Networks and Distributed Computing
  6.  *        Computing & Communications
  7.  *        University of Washington
  8.  *        Administration Building, AG-44
  9.  *        Seattle, WA  98195
  10.  *        Internet: MRC@CAC.Washington.EDU
  11.  *
  12.  * Date:    24 May 1993
  13.  * Last Edited:    29 May 1994
  14.  *
  15.  * Copyright 1994 by the University of Washington
  16.  *
  17.  *  Permission to use, copy, modify, and distribute this software and its
  18.  * documentation for any purpose and without fee is hereby granted, provided
  19.  * that the above copyright notice appears in all copies and that both the
  20.  * above copyright notice and this permission notice appear in supporting
  21.  * documentation, and that the name of the University of Washington not be
  22.  * used in advertising or publicity pertaining to distribution of the software
  23.  * without specific, written prior permission.  This software is made
  24.  * available "as is", and
  25.  * THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
  26.  * WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED
  27.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND IN
  28.  * NO EVENT SHALL THE UNIVERSITY OF WASHINGTON BE LIABLE FOR ANY SPECIAL,
  29.  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  30.  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT
  31.  * (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION
  32.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  33.  *
  34.  */
  35.  
  36.  
  37. #include <ctype.h>
  38. #include <stdio.h>
  39. #include "mail.h"
  40. #include "osdep.h"
  41. #include "dummy.h"
  42. #include "misc.h"
  43.  
  44. /* Dummy routines */
  45.  
  46.  
  47. /* Driver dispatch used by MAIL */
  48.  
  49. DRIVER dummydriver = {
  50.   "dummy",            /* driver name */
  51.   (DRIVER *) NIL,        /* next driver */
  52.   dummy_valid,            /* mailbox is valid for us */
  53.   dummy_parameters,        /* manipulate parameters */
  54.   dummy_find,            /* find mailboxes */
  55.   dummy_find_bboards,        /* find bboards */
  56.   dummy_find_all,        /* find all mailboxes */
  57.   dummy_find_all_bboards,    /* find all bboards */
  58.   dummy_subscribe,        /* subscribe to mailbox */
  59.   dummy_unsubscribe,        /* unsubscribe from mailbox */
  60.   dummy_subscribe_bboard,    /* subscribe to bboard */
  61.   dummy_unsubscribe_bboard,    /* unsubscribe from bboard */
  62.   dummy_create,            /* create mailbox */
  63.   dummy_delete,            /* delete mailbox */
  64.   dummy_rename,            /* rename mailbox */
  65.   dummy_open,            /* open mailbox */
  66.   dummy_close,            /* close mailbox */
  67.   dummy_fetchfast,        /* fetch message "fast" attributes */
  68.   dummy_fetchflags,        /* fetch message flags */
  69.   dummy_fetchstructure,        /* fetch message structure */
  70.   dummy_fetchheader,        /* fetch message header only */
  71.   dummy_fetchtext,        /* fetch message body only */
  72.   dummy_fetchbody,        /* fetch message body section */
  73.   dummy_setflag,        /* set message flag */
  74.   dummy_clearflag,        /* clear message flag */
  75.   dummy_search,            /* search for message based on criteria */
  76.   dummy_ping,            /* ping mailbox to see if still alive */
  77.   dummy_check,            /* check for new messages */
  78.   dummy_expunge,        /* expunge deleted messages */
  79.   dummy_copy,            /* copy messages to another mailbox */
  80.   dummy_move,            /* move messages to another mailbox */
  81.   dummy_append,            /* append string message to mailbox */
  82.   dummy_gc            /* garbage collect stream */
  83. };
  84.  
  85.  
  86.                 /* prototype stream */
  87. MAILSTREAM dummyproto = {&dummydriver};
  88.  
  89. /* Dummy validate mailbox
  90.  * Accepts: mailbox name
  91.  * Returns: our driver if name is valid, NIL otherwise
  92.  */
  93.  
  94. DRIVER *dummy_valid (char *name)
  95. {
  96.   char tmp[MAILTMPLEN];
  97.                 /* must be valid local mailbox */
  98.   return (name && *name && (*name != '*') && (*name != '{') &&
  99.                 /* INBOX is always accepted */
  100.       ((!strcmp (ucase (strcpy (tmp,name)),"INBOX"))))
  101.     ? &dummydriver : NIL;
  102. }
  103.  
  104.  
  105. /* Dummy manipulate driver parameters
  106.  * Accepts: function code
  107.  *        function-dependent value
  108.  * Returns: function-dependent return value
  109.  */
  110.  
  111. void *dummy_parameters (long function,void *value)
  112. {
  113.   return NIL;
  114. }
  115.  
  116. /* Dummy find list of subscribed mailboxes
  117.  * Accepts: mail stream
  118.  *        pattern to search
  119.  */
  120.  
  121. void dummy_find (MAILSTREAM *stream,char *pat)
  122. {
  123.                 /* return silently */
  124. }
  125.  
  126.  
  127. /* Dummy find list of subscribed bboards
  128.  * Accepts: mail stream
  129.  *        pattern to search
  130.  */
  131.  
  132. void dummy_find_bboards (MAILSTREAM *stream,char *pat)
  133. {
  134.                 /* return silently */
  135. }
  136.  
  137.  
  138. /* Dummy find list of all mailboxes
  139.  * Accepts: mail stream
  140.  *        pattern to search
  141.  */
  142.  
  143. void dummy_find_all (MAILSTREAM *stream,char *pat)
  144. {
  145.                 /* always an INBOX */
  146.   if (pmatch ("INBOX",pat)) mm_mailbox ("INBOX");
  147. }
  148.  
  149.  
  150. /* Dummy find list of all bboards
  151.  * Accepts: mail stream
  152.  *        pattern to search
  153.  */
  154.  
  155. void dummy_find_all_bboards (MAILSTREAM *stream,char *pat)
  156. {
  157.                 /* return silently */
  158. }
  159.  
  160. /* Dummy subscribe to mailbox
  161.  * Accepts: mail stream
  162.  *        mailbox to add to subscription list
  163.  * Returns: T on success, NIL on failure
  164.  */
  165.  
  166. long dummy_subscribe (MAILSTREAM *stream,char *mailbox)
  167. {
  168.   return NIL;            /* always fails */
  169. }
  170.  
  171.  
  172. /* Dummy unsubscribe to mailbox
  173.  * Accepts: mail stream
  174.  *        mailbox to delete from subscription list
  175.  * Returns: T on success, NIL on failure
  176.  */
  177.  
  178. long dummy_unsubscribe (MAILSTREAM *stream,char *mailbox)
  179. {
  180.   return NIL;            /* always fails */
  181. }
  182.  
  183.  
  184. /* Dummy subscribe to bboard
  185.  * Accepts: mail stream
  186.  *        bboard to add to subscription list
  187.  * Returns: T on success, NIL on failure
  188.  */
  189.  
  190. long dummy_subscribe_bboard (MAILSTREAM *stream,char *mailbox)
  191. {
  192.   return NIL;            /* always fails */
  193. }
  194.  
  195.  
  196. /* Dummy unsubscribe to bboard
  197.  * Accepts: mail stream
  198.  *        bboard to delete from subscription list
  199.  * Returns: T on success, NIL on failure
  200.  */
  201.  
  202. long dummy_unsubscribe_bboard (MAILSTREAM *stream,char *mailbox)
  203. {
  204.   return NIL;            /* always fails */
  205. }
  206.  
  207. /* Dummy create mailbox
  208.  * Accepts: mail stream
  209.  *        mailbox name to create
  210.  *        driver type to use
  211.  * Returns: T on success, NIL on failure
  212.  */
  213.  
  214. long dummy_create (MAILSTREAM *stream,char *mailbox)
  215. {
  216.   return NIL;            /* always fails */
  217. }
  218.  
  219.  
  220. /* Dummy delete mailbox
  221.  * Accepts: mail stream
  222.  *        mailbox name to delete
  223.  * Returns: T on success, NIL on failure
  224.  */
  225.  
  226. long dummy_delete (MAILSTREAM *stream,char *mailbox)
  227. {
  228.   return NIL;            /* always fails */
  229. }
  230.  
  231.  
  232. /* Mail rename mailbox
  233.  * Accepts: mail stream
  234.  *        old mailbox name
  235.  *        new mailbox name
  236.  * Returns: T on success, NIL on failure
  237.  */
  238.  
  239. long dummy_rename (MAILSTREAM *stream,char *old,char *new)
  240. {
  241.   return NIL;            /* always fails */
  242. }
  243.  
  244. /* Dummy open
  245.  * Accepts: stream to open
  246.  * Returns: stream on success, NIL on failure
  247.  */
  248.  
  249. MAILSTREAM *dummy_open (MAILSTREAM *stream)
  250. {
  251.   int fd;
  252.   char tmp[MAILTMPLEN];
  253.                 /* OP_PROTOTYPE call or silence */
  254.   if (!stream || stream->silent) return NIL;
  255.   if (strcmp (ucase (strcpy (tmp,stream->mailbox)),"INBOX")) {
  256.     sprintf (tmp,"Not a mailbox: %s",stream->mailbox);
  257.     mm_log (tmp,ERROR);
  258.     return NIL;            /* always fails */
  259.   }
  260.   if (!stream->silent) {    /* only if silence not requested */
  261.     mail_exists (stream,0);    /* say there are 0 messages */
  262.     mail_recent (stream,0);
  263.   }
  264.   return stream;        /* return success */
  265. }
  266.  
  267.  
  268. /* Dummy close
  269.  * Accepts: MAIL stream
  270.  */
  271.  
  272. void dummy_close (MAILSTREAM *stream)
  273. {
  274.                 /* return silently */
  275. }
  276.  
  277. /* Dummy fetch fast information
  278.  * Accepts: MAIL stream
  279.  *        sequence
  280.  */
  281.  
  282. void dummy_fetchfast (MAILSTREAM *stream,char *sequence)
  283. {
  284.   fatal ("Impossible dummy_fetchfast");
  285. }
  286.  
  287.  
  288. /* Dummy fetch flags
  289.  * Accepts: MAIL stream
  290.  *        sequence
  291.  */
  292.  
  293. void dummy_fetchflags (MAILSTREAM *stream,char *sequence)
  294. {
  295.   fatal ("Impossible dummy_fetchflags");
  296. }
  297.  
  298.  
  299. /* Dummy fetch envelope
  300.  * Accepts: MAIL stream
  301.  *        message # to fetch
  302.  *        pointer to return body
  303.  * Returns: envelope of this message, body returned in body value
  304.  */
  305.  
  306. ENVELOPE *dummy_fetchstructure (MAILSTREAM *stream,long msgno,BODY **body)
  307. {
  308.   fatal ("Impossible dummy_fetchstructure");
  309.   return NIL;
  310. }
  311.  
  312.  
  313. /* Dummy fetch message header
  314.  * Accepts: MAIL stream
  315.  *        message # to fetch
  316.  * Returns: message header in RFC822 format
  317.  */
  318.  
  319. char *dummy_fetchheader (MAILSTREAM *stream,long msgno)
  320. {
  321.   fatal ("Impossible dummy_fetchheader");
  322.   return NIL;
  323. }
  324.  
  325. /* Dummy fetch message text (body only)
  326.  * Accepts: MAIL stream
  327.  *        message # to fetch
  328.  * Returns: message text in RFC822 format
  329.  */
  330.  
  331. char *dummy_fetchtext (MAILSTREAM *stream,long msgno)
  332. {
  333.   fatal ("Impossible dummy_fetchtext");
  334.   return NIL;
  335. }
  336.  
  337.  
  338. /* Berkeley fetch message body as a structure
  339.  * Accepts: Mail stream
  340.  *        message # to fetch
  341.  *        section specifier
  342.  * Returns: pointer to section of message body
  343.  */
  344.  
  345. char *dummy_fetchbody (MAILSTREAM *stream,long m,char *sec,unsigned long *len)
  346. {
  347.   fatal ("Impossible dummy_fetchbody");
  348.   return NIL;
  349. }
  350.  
  351.  
  352. /* Dummy set flag
  353.  * Accepts: MAIL stream
  354.  *        sequence
  355.  *        flag(s)
  356.  */
  357.  
  358. void dummy_setflag (MAILSTREAM *stream,char *sequence,char *flag)
  359. {
  360.   fatal ("Impossible dummy_setflag");
  361. }
  362.  
  363.  
  364. /* Dummy clear flag
  365.  * Accepts: MAIL stream
  366.  *        sequence
  367.  *        flag(s)
  368.  */
  369.  
  370. void dummy_clearflag (MAILSTREAM *stream,char *sequence,char *flag)
  371. {
  372.   fatal ("Impossible dummy_clearflag");
  373. }
  374.  
  375.  
  376. /* Dummy search for messages
  377.  * Accepts: MAIL stream
  378.  *        search criteria
  379.  */
  380.  
  381. void dummy_search (MAILSTREAM *stream,char *criteria)
  382. {
  383.                 /* return silently */
  384. }
  385.  
  386. /* Dummy ping mailbox
  387.  * Accepts: MAIL stream
  388.  * Returns: T if stream alive, else NIL
  389.  * No-op for readonly files, since read/writer can expunge it from under us!
  390.  */
  391.  
  392. long dummy_ping (MAILSTREAM *stream)
  393. {
  394.   return T;
  395. }
  396.  
  397.  
  398. /* Dummy check mailbox
  399.  * Accepts: MAIL stream
  400.  * No-op for readonly files, since read/writer can expunge it from under us!
  401.  */
  402.  
  403. void dummy_check (MAILSTREAM *stream)
  404. {
  405.   dummy_ping (stream);        /* invoke ping */
  406. }
  407.  
  408.  
  409. /* Dummy expunge mailbox
  410.  * Accepts: MAIL stream
  411.  */
  412.  
  413. void dummy_expunge (MAILSTREAM *stream)
  414. {
  415.                 /* return silently */
  416. }
  417.  
  418. /* Dummy copy message(s)
  419.  * Accepts: MAIL stream
  420.  *        sequence
  421.  *        destination mailbox
  422.  * Returns: T if copy successful, else NIL
  423.  */
  424.  
  425. long dummy_copy (MAILSTREAM *stream,char *sequence,char *mailbox)
  426. {
  427.   fatal ("Impossible dummy_copy");
  428.   return NIL;
  429. }
  430.  
  431.  
  432. /* Dummy move message(s)
  433.  * Accepts: MAIL stream
  434.  *        sequence
  435.  *        destination mailbox
  436.  * Returns: T if move successful, else NIL
  437.  */
  438.  
  439. long dummy_move (MAILSTREAM *stream,char *sequence,char *mailbox)
  440. {
  441.   fatal ("Impossible dummy_move");
  442.   return NIL;
  443. }
  444.  
  445. /* Dummy append message string
  446.  * Accepts: mail stream
  447.  *        destination mailbox
  448.  *        stringstruct of message to append
  449.  * Returns: T on success, NIL on failure
  450.  */
  451.  
  452. long dummy_append (MAILSTREAM *stream,char *mailbox,char *flags,char *date,
  453.            STRING *message)
  454. {
  455.   char tmp[MAILTMPLEN];
  456.   sprintf (tmp,"Can't append to %s",mailbox);
  457.   mm_log (tmp,ERROR);        /* pass up error */
  458.   return NIL;            /* always fails */
  459. }
  460.  
  461.  
  462. /* Dummy garbage collect stream
  463.  * Accepts: mail stream
  464.  *        garbage collection flags
  465.  */
  466.  
  467. void dummy_gc (MAILSTREAM *stream,long gcflags)
  468. {
  469.                 /* return silently */
  470. }
  471.